﻿using DotNetFramework.CAP.Core.Logger;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DotnetFramework.CAP.Nlog
{
    public class Logger : DotNetFramework.CAP.Core.Logger.ILogger
    {
        NLog.Logger logger;
        public Logger()
        {
            logger = NLog.LogManager.GetCurrentClassLogger();
        }
        public Logger(Type type)
        {
            logger = NLog.LogManager.GetLogger(type.FullName);
        }

        public void LogCritical(string message, params object[] args)
        {
            logger.Fatal(message, args);
        }

        public void LogDebug(string message, params object[] args)
        {
            logger.Debug(message, args);
        }

        public void LogError(string message, params object[] args)
        {
            logger.Error(message, args);
        }

        public void LogError(Exception e, string message, params object[] args)
        {
            logger.Error(e, message, args);
        }

        public void LogInformation(string message, params object[] args)
        {
            logger.Info(message, args);
        }

        public void LogTrace(string message, params object[] args)
        {
            logger.Info(message, args);
        }

        public void LogWarning(string message, params object[] args)
        {
            logger.Warn(message, args);
        }

        public void LogWarning(Exception e, string message, params object[] args)
        {
            logger.Warn(e, message, args);
        }

        public void LogWarning(int num, Exception e, string message, params object[] args)
        {
            logger.Warn(e, message, args);
        }
    }
    public class LoggerFactory : DotNetFramework.CAP.Core.Logger.ILoggerFactory
    {
        //public ILogger CreateLogger()
        //{
        //    return new Logger();
        //}
        public DotNetFramework.CAP.Core.Logger.ILogger CreateLogger<T>()
        {
            return new Logger(typeof(T));
        }
    }
}
